package com.owc.common.tool;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author xiaom
 * @Date 2019/12/2 14:29
 * @Version 1.0.0
 * @Description <>
 **/
public class ValidationUtils {

    /**
     * 验证手机号
     * 有效返回true,否则返回false
     */
    public static boolean isMobile(String mobiles) {
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4])|(18[0-9])|(17[0-9])|(147))\\d{8}$");
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }

    /**
     * 验证ETH钱包地址
     */
    public static boolean isEthWalletAddress(String address){
        Pattern p = Pattern.compile("^0x[0-9a-fA-F]{40}$");
        Matcher m = p.matcher(address);
        return m.matches();
    }

    /**
     * 验证BTC钱包地址
     */
    public static boolean isBtcWalletAddress(String address){
        Pattern p = Pattern.compile("/^(1|3)[a-zA-Z\\d]{24,33}$/");
        Matcher m = p.matcher(address);
        return m.matches();
    }
}
